<!DOCTYPE HTML>
<html>
<head>
<title>validation</title>

<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="Ultra Modern Responsive web template, Bootstrap Web Templates, Flat Web Templates, Android Compatible web template, 
SmartPhone Compatible web template, free WebDesigns for Nokia, Samsung, LG, SonyEricsson, Motorola web design" />
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
<!-- Bootstrap Core CSS -->
<link href="/behind/css/bootstrap.css" rel='stylesheet' type='text/css' />
<link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="/css/fileinput.min.css" />
<!-- Custom CSS -->
<link href="/behind/css/style.css" rel='stylesheet' type='text/css' />
<!-- font CSS -->
<link rel="icon" href="favicon.ico" type="/behind/image/x-icon" />
<!-- font-awesome icons -->
<link href="/behind/css/font-awesome.css" rel="stylesheet" /> 

<!-- //font-awesome icons -->
 <!-- js-->
<script src="/behind/js/jquery-1.11.1.min.js"></script>
<script src="/behind/js/modernizr.custom.js"></script>
<!--webfonts
<link href='http://fonts.useso.com/css?family=Comfortaa:400,700,300' rel='stylesheet' type='text/css' />
<link href='http://fonts.useso.com/css?family=Muli:400,300,300italic,400italic' rel='stylesheet' type='text/css' />
<!--//webfonts--> 
<!-- Metis Menu -->
<script src="/behind/js/metisMenu.min.js"></script>
<script src="/behind/js/custom.js"></script>
<link href="/behind/css/custom.css" rel="stylesheet" />
<!--//Metis Menu -->
</head> 
<body class="cbp-spmenu-push">
	<div class="main-content">
		<!--left-fixed -navigation-->
		<div class="sidebar" role="navigation">
            <div class="navbar-collapse">
				<nav class="cbp-spmenu cbp-spmenu-vertical cbp-spmenu-right dev-page-sidebar mCustomScrollbar _mCS_1 mCS-autoHide mCS_no_scrollbar" id="cbp-spmenu-s1">
					<div class="scrollbar scrollbar1">
						<ul class="nav" id="side-menu">
							<li>
								<a href="index.html"><i class="fa fa-home nav_icon"></i>Dashboard</a>
							</li>
							<li>
								<a href="#"><i class="fa fa-cogs nav_icon"></i>Components <span class="fa arrow"></span></a>
								<ul class="nav nav-second-level collapse">
									<li>
										<a href="gallery.html">Gallery</a>
									</li>
									<li>
										<a href="grid.html">Grid</a>
									</li>
								</ul>
								<!-- /nav-second-level -->
							</li>
							<li>
								<a href="#"><i class="fa fa-book nav_icon"></i>Elements <span class="fa arrow"></span></a>
								<ul class="nav nav-second-level collapse">
									<li>
										<a href="buttons.html">Buttons</a>
									</li>
									<li>
										<a href="typography.html">Typography</a>
									</li>
									<li>
										<a href="icon.html">Icon</a>
									</li>
								</ul>
								<!-- /nav-second-level -->
							</li>
							<li>
								<a href="widgets.html"><i class="fa fa-th-large nav_icon"></i>Widgets</a>
							</li>
							
							<li>
								<a href="#"><i class="fa fa-check-square-o nav_icon"></i>Forms<span class="fa arrow"></span></a>
								<ul class="nav nav-second-level collapse">
									<li>
										<a href="inputs.html">Inputs</a>
									</li>
									<li>
										<a href="validation.html">Form Validatioaaaaaaaaaaaaaaaaaaaan</a>
									</li>
								</ul>
								<!-- //nav-second-level -->
							</li>
							<li>
								<a href="#"><i class="fa fa-envelope nav_icon"></i>Mailbox<span class="fa arrow"></span></a>
								<ul class="nav nav-second-level collapse">
									<li>
										<a href="inbox.html">Inbox</a>
									</li>
									<li>
										<a href="inboxdetails.html">Inbox Details</a>
									</li>
								</ul>
								<!-- //nav-second-level -->
							</li>
							<li>
								<a href="maps.html"><i class="fa fa-location-arrow nav_icon"></i>Maps</a>
							</li>
							<li>
								<a href="#"><i class="fa fa-file-text-o nav_icon"></i>Pages<span class="fa arrow"></span></a>
								<ul class="nav nav-second-level collapse">
									<li>
										<a href="login.html">Login</a>
									</li>
									<li>
										<a href="signup.html">SignUp</a>
									</li>
									<li>
										<a href="blank-page.html">Blank Page</a>
									</li>
								</ul>
								<!-- //nav-second-level -->
							</li>
							<li>
								<a href="charts.html" class="chart-nav"><i class="fa fa-bar-chart nav_icon"></i>Charts</a>
							</li>
							<li>
								<a href="#" class="chart11-nav"><i class="fa fa-list-ul nav_icon"></i>Extras<span class="fa arrow"></span></a>
								<ul class="nav nav-second-level collapse">
									<li>
										<a href="tables.html">Tables</a>
									</li>
									<li>
										<a href="404.html">404 Page</a>
									</li>
								</ul>
								<!-- //nav-second-level -->
							</li>
						</ul>
					</div>
					<!-- //sidebar-collapse -->
				</nav>
			</div>
		</div>
		<!--left-fixed -navigation-->
		<!-- header-starts -->
		<div class="sticky-header header-section ">
			<div class="header-left">
				<!--logo -->
				<div class="logo">
					<a href="/index.html"><h1>去主页看看</h1></a>
				</div>
				
			</div>
			<div class="header-right">
					<!--toggle button start-->
					<div class="search-box">
					
				</div>
				<button id="showLeftPush"><i class="fa fa-bars"></i></button>
				<div class="clearfix"> </div>
				<!--toggle button end-->
			</div>
			<div class="clearfix"> </div>	
		</div>
		<!-- //header-ends -->
		<div id="page-wrapper">
			<div class="main-page">
				<div class="validation-section">
					<h2>添加文章</h2>
					<div class="col-md-6 validation-grid">
						<h4><span>dynamic</span> Form</h4>
						<div class="validation-grid1">
							<div class="valid-top">
								<form id="defaultForm" method="post" class="form-horizontal" >
									<div class="form-group">
										<label class="col-lg-3 control-label">文章标题</label>
										<div class="col-lg-5">
											<input type="text" id="title" class="form-control" name="username" autocomplete="off" />
										</div>
									</div>

									<div class="form-group">
										<label class="col-lg-3 control-label">文章描述</label>
										<div class="col-lg-8">
											<textarea type="text" id="description" class="form-control" name="email" autocomplete="off" />
										</div>
									</div>
									  <div class="form-group">
			                            <label class="col-lg-3 control-label">选择所属模块</label>
			                            <div class="col-lg-5">
			                                <select class="form-control" id="module" name="author" >
			                                    <option value="">-- choose one --</option>
			                                    <option th:each="module:${moduleList}" th:value="${module.id}" th:text="${module.name}"></option>
			                                </select>
			                            </div>
			                        </div>
									<div class="form-group">
			                            <label class="col-lg-3 control-label">选择作者</label>
			                            <div class="col-lg-5">
			                                <select class="form-control" name="module" id="author">
			                                    <option value="">-- choose one--</option>
			                                    <option th:each="author:${authorList}" th:value="${author.id}" th:text="${author.name}">France</option>
			                                </select>
			                            </div>
			                        </div>
			                        <div class="form-group">
										<label class="col-lg-3 control-label">标签(用-分割)</label>
										<div class="col-lg-5">
											<input type="text" id="target" class="form-control" name="target" autocomplete="off" />
										</div>
									</div>
			                   </form>
									<label class="col-lg-3 control-label">选择图片</label>
									<div>
										<form class="form-horizontal required-validate" action="/pictrueUpload" enctype="multipart/form-data" method="post" onsubmit="return iframeCallback(this, pageAjaxDone)">
	
										    <div class="form-group">
										        <div class="col-md-10 tl th">
										            <input type="file" id="uploadfile1" name="image" class="projectfile" value="${deal.image}" />
										        </div>
										    </div>  
										    <!--  
										    <div class="form-group text-center ">
										        <div class="col-md-10 col-md-offset-1">
										            <button type="submit" class="btn btn-primary btn-lg">保存1</button>
										        </div>
										    </div>-->
										</form>
									</div>    
									
									<input type="hidden" id="imgsrc" value=""/>
									
									<div class="form-group">
										<div class="col-lg-9 col-lg-offset-3">
											<button id="sub" onclick="beforeSub();"class="btn btn-primary">Submit</button>
										</div>
									</div>
							</div>
							
							<script type="text/javascript" src="/behind/js/formValidation.js"></script>
							<script type="text/javascript" src="/behind/js/bootstrap.js"></script>
							<div class="valid-top2">
							
                </div>

				</div>
			</div>
		</div>
		
					
					<div class="col-md-6 validation-grid">
						<h4><span>User Assist </span> Elements</h4>
						<div class="vlid-grid2">
						
						
				
				
						<div class="valid-top3">
						 <section>
							<form id="defaultForm" method="post" class="form-horizontal" action="inputs.html">
								<div class="form-group">
									<label class="col-sm-3 control-label">新增模块</label>
									<div class="col-sm-4">
										<input type="text" class="form-control" id="moduleName" placeholder="模块名称.." />
									</div>
								</div>
	
								<div class="form-group">
			                            <label class="col-lg-3 control-label">所属模块</label>
			                            <div class="col-lg-5">
			                                <select class="form-control" id="belongModuleId"  >
			                                    <option value="">--选择一个模块 --</option>
			                                    <option th:each="module:${moduleList1}" th:value="${module.id}" th:text="${module.name}"></option>
			                                </select>
			                            </div>
			                        </div>
							
								<div class="col-md-3 grid-form">
									<h5>是否为主模块(显示在首页上面的) </h5>
								</div>
									<div class="col-md-9 grid-form1" id="isMainModule" >
									
									<div class="radio block"><label><input type="radio" value="1" name="moduleId"> 是</label></div>
									<div class="radio block"><label><input type="radio" value="2" name="moduleId" checked="">否</label></div>
								</div>
								<div class="clearfix"></div>
							</form>
								<div class="form-group">
										<div class="col-lg-9 col-lg-offset-3">
											<button id="sub" onclick="moduleSub();"class="btn btn-primary">提交模块</button>
										</div>
								</div>							
							 </section>
						</div>
						
						
						
						
						
						<!-- 新增作者ssssssssssssssssssssssssssss -->
						
						
						
						<a href="/beforeAuthor">去新增一个作者</a>
					
						
						
						<!-- 新增作者eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee -->
						
						
						
						
						
					</div>
				</div>
					<div class="clearfix"></div>
				</div>
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
			</div>
					<div class="form-group">
					     <label for="title" class="col-md-2 control-label">新闻详情</label>
					     <div class="col-md-10" style="width: 100%;">
					         <script id="editor" name="detailContent" type="text/plain" style="width:1000px;height:500px;"></script>
					     </div>
					 </div>
					<button onclick="getContent()">获得内容</button>
			</div>
			<div class="copy-section">
			
			<p>Copyright &copy; 2016.Company name All rights reserved.<a target="_blank" href="http://sc.chinaz.com/moban/">&#x7F51;&#x9875;&#x6A21;&#x677F;</a></p>
		</div>
			<!-- Classie -->
				<script src="/behind/js/classie.js"></script>
				<script src="/js/fileinput.min.js"></script>
			    <script type="text/javascript" charset="utf-8" src="/ueditor/ueditor.config.js"></script>
    			<script type="text/javascript" charset="utf-8" src="/ueditor/ueditor.all.js"> </script>
    			<script type="text/javascript" charset="utf-8" src="/ueditor/lang/zh-cn/zh-cn.js"></script>
				<script>
					var menuLeft = document.getElementById( 'cbp-spmenu-s1' ),
						showLeftPush = document.getElementById( 'showLeftPush' ),
						body = document.body;
						
					showLeftPush.onclick = function() {
						classie.toggle( this, 'active' );
						classie.toggle( body, 'cbp-spmenu-push-toright' );
						classie.toggle( menuLeft, 'cbp-spmenu-open' );
						disableOther( 'showLeftPush' );
					};
					

					function disableOther( button ) {
						if( button !== 'showLeftPush' ) {
							classie.toggle( showLeftPush, 'disabled' );
						}
					}
				</script>
			<!-- Bootstrap Core JavaScript --> 
				
				<script type="text/javascript" src="/behind/js/bootstrap.min.js"></script>
				<!--scrolling js-->
				<script src="/behind/js/jquery.nicescroll.js"></script>
				<script src="/behind/js/scripts.js"></script>
				<!--//scrolling js-->
				<script type="text/javascript">
				
				//初始化fileinput控件（第一次初始化）
							function iframeCallback(form, callback) {
							alert("a")
			    YUNM.debug("带文件上传处理");
			
			    var $form = $(form), $iframe = $("#callbackframe");
				
			    var data = $form.data('bootstrapValidator');
			    if (data) {
			        if (!data.isValid()) {
			            return false;
			        }
			    }
			
			    // 富文本编辑器
			    $("div.summernote", $form).each(function() {
			        var $this = $(this);
			
			        if (!$this.summernote('isEmpty')) {
			            var editor = "<input type='hidden' name='" + $this.attr("name") + "' value='" + $this.summernote('code') + "' />";
			            $form.append(editor);
			        } else {
			            $.showErr("请填写项目详情");
			            return false;
			        }
			
			    });
			
			    if ($iframe.size() == 0) {
			        $iframe = $("<iframe id='callbackframe' name='callbackframe' src='about:blank' style='display:none'></iframe>").appendTo("body");
			    }
			    if (!form.ajax) {
			        $form.append('<input type="hidden" name="ajax" value="1" />');
			    }
			    form.target = "callbackframe";
			
			    _iframeResponse($iframe[0], callback || YUNM.ajaxDone);
			}
			function _iframeResponse(iframe, callback) {
			    var $iframe = $(iframe), $document = $(document);
			
			    $document.trigger("ajaxStart");
			
			    $iframe.bind("load", function(event) {
			        $iframe.unbind("load");
			        $document.trigger("ajaxStop");
			
			        if (iframe.src == "javascript:'%3Chtml%3E%3C/html%3E';" || // For
			        // Safari
			        iframe.src == "javascript:'<html></html>';") { // For FF, IE
			            return;
			        }
			
			        var doc = iframe.contentDocument || iframe.document;
			
			        // fixing Opera 9.26,10.00
			        if (doc.readyState && doc.readyState != 'complete')
			            return;
			        // fixing Opera 9.64
			        if (doc.body && doc.body.innerHTML == "false")
			            return;
			
			        var response;
			
			        if (doc.XMLDocument) {
			            // response is a xml document Internet Explorer property
			            response = doc.XMLDocument;
			        } else if (doc.body) {
			            try {
			                response = $iframe.contents().find("body").text();
			                response = jQuery.parseJSON(response);
			            } catch (e) { // response is html document or plain text
			                response = doc.body.innerHTML;
			            }
			        } else {
			            // response is a xml document
			            response = doc;
			        }
			
			        callback(response);
			    });
			}
				
							function initFileInput(ctrlName,uploadUrl) {      
						        var control = $('#' + ctrlName);   
						        control.fileinput({  
						            language: 'zh', //设置语言  
						            uploadUrl: uploadUrl,  //上传地址  
						            showUpload: false, //是否显示上传按钮  
						            showRemove:true,  
						             dropZoneEnabled: false,  
						            showCaption: true,//是否显示标题  
						            allowedPreviewTypes: ['image'],  
						                allowedFileTypes: ['image'],  
						                allowedFileExtensions:  ['jpg', 'png'],  
						                maxFileSize : 2000,  
						            maxFileCount: 1,  
						            //initialPreview: [   
						                    //预览图片的设置  
						              //      "<img src='http://127.0.0.1:8080/NewsManageSys/plugin/umeditor1_2_2/jsp/upload/20161030/55061                       477813913474.jpg' class='file-preview-image' alt='肖像图片' title='肖像图片'>",  
						            //],  
						              
						        }).on("filebatchselected", function(event, files) {  
						          	
						            $(this).fileinput("upload");  
						            })  
						            .on("fileuploaded", function(event,data,result) {
						           	//解析json对象
						            //alert(JSON.stringify(data.response));
						              $("#imgsrc").val(data.response.aaa);
						             $("#path").attr("value",data.response);  
						        });  
						    }  
							 
						    
						function beforeSub(){
							var title = $("#title").val();
							var description = $("#description").val();
							var module = $("#module").val();
							var author = $("#author").val();
							var imgsrc = $("#imgsrc").val();
					        var fuwenben = "<div>"+UE.getEditor('editor').getContent()+"</div>";
					        var wenben = UE.getEditor('editor').getContent();
					        var moreimg = "";
					        var target = $("#targer").val();
							$(fuwenben).find("img").each(function(){
								moreimg = moreimg +　$(this).attr("src") +","
							})
							
							var data1 ={
							"title":title,
							"context":wenben,
							"authorId":author,
							"moduleId":module,
							"description":description,
							"imgsrc":imgsrc,
							"context":wenben,
							"target" : target
							}
							$.ajax({
								url : "insertArticle",
								type: "post",
								dataType : "json",
								data : data1,
					
								success : function(data) {
								alert(data.aaa)
									if (data == '1') {
										return;
									}
									
								}	
							});
							
						}
						    
						    
						    
					 	$(document).ready(function(){  	
							 var path="/pictrueUpload";  
       						initFileInput("uploadfile1",path); 
							createEditor();
							
						});
						  //百度编辑器
						  var ue = UE.getEditor('editor');

					
					    function isFocus(e){
					        alert(UE.getEditor('editor').isFocus());
					        UE.dom.domUtils.preventDefault(e)
					    }
					    function setblur(e){
					        UE.getEditor('editor').blur();
					        UE.dom.domUtils.preventDefault(e)
					    }
					    function insertHtml() {
					        var value = prompt('插入html代码', '');
					        UE.getEditor('editor').execCommand('insertHtml', value)
					    }
					    function createEditor() {
					        enableBtn();
					        UE.getEditor('editor');
					    }
					    function getAllHtml() {
					        alert(UE.getEditor('editor').getAllHtml())
					    }
					    function getContent() {
					        var arr = [];
					        arr.push("使用editor.getContent()方法可以获得编辑器的内容");
					        arr.push("内容为：");
					        arr.push(UE.getEditor('editor').getContent());
					        var ss = UE.getEditor('editor').getContent();
					        alert(arr.join("\n"));
					    }
					    function getPlainTxt() {
					        var arr = [];
					        arr.push("使用editor.getPlainTxt()方法可以获得编辑器的带格式的纯文本内容");
					        arr.push("内容为：");
					        arr.push(UE.getEditor('editor').getPlainTxt());
					        alert(arr.join('\n'))
					    }
					    function setContent(isAppendTo) {
					        var arr = [];
					        arr.push("使用editor.setContent('欢迎使用ueditor')方法可以设置编辑器的内容");
					        UE.getEditor('editor').setContent('欢迎使用ueditor', isAppendTo);
					        alert(arr.join("\n"));
					    }
					    function setDisabled() {
					        UE.getEditor('editor').setDisabled('fullscreen');
					        disableBtn("enable");
					    }
					
					    function setEnabled() {
					        UE.getEditor('editor').setEnabled();
					        enableBtn();
					    }
					
					    function getText() {
					        //当你点击按钮时编辑区域已经失去了焦点，如果直接用getText将不会得到内容，所以要在选回来，然后取得内容
					        var range = UE.getEditor('editor').selection.getRange();
					        range.select();
					        var txt = UE.getEditor('editor').selection.getText();
					        alert(txt)
					    }
					
					    function getContentTxt() {
					        var arr = [];
					        arr.push("使用editor.getContentTxt()方法可以获得编辑器的纯文本内容");
					        arr.push("编辑器的纯文本内容为：");
					        arr.push(UE.getEditor('editor').getContentTxt());
					        alert(arr.join("\n"));
					    }
					    function hasContent() {
					        var arr = [];
					        arr.push("使用editor.hasContents()方法判断编辑器里是否有内容");
					        arr.push("判断结果为：");
					        arr.push(UE.getEditor('editor').hasContents());
					        alert(arr.join("\n"));
					    }
					    function setFocus() {
					        UE.getEditor('editor').focus();
					    }
					    function deleteEditor() {
					        disableBtn();
					        UE.getEditor('editor').destroy();
					    }
					    function disableBtn(str) {
					        var div = document.getElementById('btns');
					        var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
					        for (var i = 0, btn; btn = btns[i++];) {
					            if (btn.id == str) {
					                UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
					            } else {
					                btn.setAttribute("disabled", "true");
					            }
					        }
					    }
					    function enableBtn() {
					        var div = document.getElementById('btns');
					        var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
					        for (var i = 0, btn; btn = btns[i++];) {
					            UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
					        }
					    }
					
					    function getLocalData () {
					        alert(UE.getEditor('editor').execCommand( "getlocaldata" ));
					    }
					
					    function clearLocalData () {
					        UE.getEditor('editor').execCommand( "clearlocaldata" );
					        alert("已清空草稿箱")
					    }
						
						function moduleSub(){
							var moduleName = $("#moduleName").val();
							var belongModuleId = $("#belongModuleId").val();
							var is =$("#isMainModule input[name='moduleId']:checked").val();
							alert(moduleName);
							alert(belongModuleId);
							alert(is);
							if(is==1){
								//是主模块
									var data1 ={
							"moduleName":moduleName,
							"belongModuleId":1
							}
							
								$.ajax({
									url : "insertModule",
									type: "post",
									dataType : "json",
									data : data1,
						
									success : function(data) {
									alert(data.result)
										if (data == '1') {
											return;
										}
										
									}
								});	
								
							}else{
								//不是主模块 需要选择子模块
								if(belongModuleId==""){
									alert("请选择一个所属模块！")
									return false;
								}
								
								var data1 ={
									"moduleName":moduleName,
									"belongModuleId":belongModuleId
								}
								
									$.ajax({
									url : "insertModule",
									type: "post",
									dataType : "json",
									data : data1,
						
									success : function(data) {
									alert(data.result)
										if (data == '1') {
											return;
										}
										
									}	
								});
								
								
							}
							
						}
						
						
										
						
						
						
						
								</script>
</body>
</html>